#define _CRT_SECURE_NO_WARNINGS 1
#include <climits>
#include <iostream>
using namespace std;
bool IsLeap(int year)
{
    return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}

int GetMonthday(int year, int month)
{
    int days[13] = { 29, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    if (month == 2 && IsLeap(year))
    {
        month = 0;
    }
    return days[month];
}
int Getday(int year, int month, int day)
{
    int num = 0;
    for (int i = 1; i < month; i++)
    {
        num += GetMonthday(year, i);
    }
    num += day;
    return num;
}
int main() {
    int year, month, day;
    cin >> year >> month >> day;
    int num = Getday(year, month, day);
    cout << num << endl;
}